package cn.edu.imnu.Controller;

import cn.edu.imnu.Service.DrugService;
import cn.edu.imnu.entity.Result;
import cn.edu.imnu.entity.dto.*;
import cn.edu.imnu.entity.vo.DoctorListvo;
import cn.edu.imnu.entity.vo.DrugListvo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@ResponseBody
@RequestMapping("/drug")
public class DrugController {
    @Autowired
    private DrugService drugService;
    @PostMapping("/drugsLocations")
    public Result getAllDoctors(@RequestBody DrugListdto drugListdto) {
        DrugListvo drugList =drugService.gerAllDrugs(drugListdto);
        return Result.success(drugList);
    }
    @PostMapping("/delete")
    public Result deleteDrug(@RequestBody Map<String, Long> requestBody) {
        Long drugId = requestBody.get("drugId");
        return drugService.deleteDrug(drugId);
    }
    @PostMapping("/update")
    public Result updateDrug(@RequestBody Drugupdatedto dto) {
        return drugService.updateDrug(dto);
    }
    @PostMapping("/add")
    public Result addDrug(@RequestBody Drugadddto dto) {
        return drugService.addDrug(dto);
    }
}
